package com.teacold.customdemo.chapter_ten;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.drawable.shapes.Shape;
import android.view.View;

public class PathShape extends Shape {
    private Path mPath;
    private float mStdWidth;
    private float mStdHight;

    private float mScaleX;
    private float mScaleY;

    public PathShape(Path mPath, float mStdWidth, float mStdHight) {
        this.mPath = mPath;
        this.mStdWidth = mStdWidth;
        this.mStdHight = mStdHight;
    }

    @Override
    public void draw(Canvas canvas, Paint paint) {
       canvas.save();
       canvas.scale(mScaleX,mScaleY);
       canvas.drawPath(mPath,paint);
       canvas.restore();
    }

    @Override
    protected void onResize(float width, float height) {
        super.onResize(width, height);
        mScaleX=width/mStdWidth;
        mScaleY=height/mStdHight;
    }
}
